<template>
   <div>
       账户<input type="text" v-model="username">
       密码<input type="password" v-model="password" @blur="mdpassword">
       昵称<input type="text" v-model="name">
       <van-button @click="ok">确认提交</van-button>
       <div v-show='code'>{{code}}</div>
   </div>
</template>

<script>
export default {
   data () {
      return {
        username:'',
        password:'',
        name:'',
        code:''
      };
   },

   methods: {
       //判断密码强弱
       mdpassword:function(){
           console.log(this.password.length);
           if (this.password == ''){
               return false;
           }
           if (this.password.length <= 5){
               this.$toast.success('密码过于简单')
           }
           else{
               this.$toast.success('密码强度高')
           }
       },
       //确认添加
       ok:function(){
           this.code = ''
           this.axios.post(this.localhost+'post_user/',this.qs.stringify({username:this.username,password:this.password,name:this.name}))
           .then(res=>{
               console.log(res);
               if(res.data.code == 0){
                   this.code = '注册失败'
               }
               else{
                   this.code = '注册成功'
                   sessionStorage.setItem('admin_name',res.data.username)
                //    localStorage.setItem('admin_name',res.data.username)
               }
           })
       }
   },

   computed: {},

   mounted() {},

   components: {}
}
</script>
<style lang='css' scoped>

</style>